using System.Collections.Generic;
using UnityEngine;

namespace GGPhysics
{
	public class CompositeLineShape : Shape
	{
		public List<LineShape> lines = new List<LineShape>();

		public override CollisionDetection.AABBBounds GetBounds(PhysicsBody.Transform currentTransform, PhysicsBody.Transform nextTransform)
		{
			CollisionDetection.AABBBounds result = default(CollisionDetection.AABBBounds);
			for (int i = 0; i < lines.Count; i++)
			{
				LineShape lineShape = lines[i];
				Vector3 vector = currentTransform.TransformLocalToWorld(lineShape.point1);
				Vector3 vector2 = currentTransform.TransformLocalToWorld(lineShape.point2);
				if (i == 0)
				{
					result.bottomLeftBound.x = MathEx.Min(vector.x, vector2.x);
					result.bottomLeftBound.y = MathEx.Min(vector.z, vector2.z);
					result.topRightBound.x = MathEx.Max(vector.x, vector2.x);
					result.topRightBound.y = MathEx.Max(vector.z, vector2.z);
				}
				else
				{
					result.bottomLeftBound.x = MathEx.Min(vector.x, vector2.x, result.bottomLeftBound.x);
					result.bottomLeftBound.y = MathEx.Min(vector.z, vector2.z, result.bottomLeftBound.y);
					result.topRightBound.x = MathEx.Max(vector.x, vector2.x, result.topRightBound.x);
					result.topRightBound.y = MathEx.Max(vector.z, vector2.z, result.topRightBound.y);
				}
			}
			return result;
		}
	}
}
